<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets" template="/template/main.xhtml">

	<ui:define name="body">
		<h:form>
			
			<h:outputText value="#{productListByQueryMB.query}" />
			
			<p:dataTable id="list" var="bean" value="#{productListByQueryMB.resultList}">
				<f:facet name="header">#{messages['product.list.table.title']}</f:facet>
				
				<p:column style="width:5%;">
					<h:selectBooleanCheckbox value="#{productListByQueryMB.selection[bean.id]}" />
				</p:column>
				
				<p:column sortBy="#{bean.itemName}">
					<f:facet name="header">#{messages['product.label.itemname']}</f:facet>
					<h:commandLink action="#{productListByQueryMB.getNextView}" actionListener="#{productListByQueryMB.clear}">
						<h:outputText value="#{bean.itemName}" />
						<f:param name="id" value="#{bean.id}" />
					</h:commandLink>
				</p:column>				
				<p:column sortBy="#{bean.description}">
					<f:facet name="header">#{messages['product.label.description']}</f:facet>
					<h:commandLink action="#{productListByQueryMB.getNextView}" actionListener="#{productListByQueryMB.clear}">
						<h:outputText value="#{bean.description}" />
						<f:param name="id" value="#{bean.id}" />
					</h:commandLink>
				</p:column>
				<p:column sortBy="#{bean.quantity}">
					<f:facet name="header">#{messages['product.label.quantity']}</f:facet>
					<h:commandLink action="#{productListByQueryMB.getNextView}" actionListener="#{productListByQueryMB.clear}">
						<h:outputText value="#{bean.quantity}"/>
						<f:param name="id" value="#{bean.id}" />
					</h:commandLink>
				</p:column>
				<p:column sortBy="#{bean.price}">
					<f:facet name="header">#{messages['product.label.price']}</f:facet>
					<h:commandLink action="#{productListByQueryMB.getNextView}" actionListener="#{productListByQueryMB.clear}">
						<h:outputText value="#{bean.price}" />
						<f:param name="id" value="#{bean.id}" />
					</h:commandLink>
				</p:column>
				<p:column sortBy="#{bean.seller.login}">
					<f:facet name="header">#{messages['product.label.seller']}</f:facet>
					<h:commandLink action="#{productListByQueryMB.getSellerView(bean.owner)}" actionListener="#{productListByQueryMB.clear}">
						<h:outputText value="#{bean.owner.user.username}" />
						<f:param name="sellerId" value="#{bean.owner.id}" />
					</h:commandLink>
				</p:column>
				
			</p:dataTable>
		</h:form>
	</ui:define>
</ui:composition>